package com.example.demo.config;

import org.springframework.context.annotation.Configuration;
import org.springframework.web.WebApplicationInitializer;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.PathMatchConfigurer;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * @Author :蕉绿
 * @Date : 2023/3/7 19:48
 * @Version : V1.0
 * @Description :
 */
@Configuration
public class AppConfig implements WebMvcConfigurer {
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(new LoginInterceptor())
                .addPathPatterns("/**")   //拦截所有请求
                .excludePathPatterns("/user/reg")   //排除的URl地址
                .excludePathPatterns("/user/login")
                .excludePathPatterns("/**/*.html");
    }

//    @Override
//    public void configurePathMatch(PathMatchConfigurer configurer) {
//        configurer.addPathPrefix("/zhangsan",c -> true);
//    }
}
